package com.ik.pbs.conection;
/*
 * ConectDB.java
 *
 * Created on 7 de septiembre de 2006, 02:46 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
//import Encapsulado.ConfigDB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


/**
 *
 * @author camacho
 */
public class ConexionDB {

    private Connection con = null;
    private String bd = "pbs";
    private String server = "127.0.0.1";
    private String name = "root";
    private String password = "prieto";
    private String url = "jdbc:mysql://" + server + "/" + bd;
    private String driver = "com.mysql.jdbc.Driver";
    private static ConexionDB conexion;

    /**
     * Creates a new instance of ConectDB
     */
    public ConexionDB() {

        try {
            Class.forName(driver);
            url = "jdbc:mysql://" + server + "/" + bd ;
            System.out.println(url);
            System.out.println((Object)bd);
            con = DriverManager.getConnection(url, name, password);
            // System.out.println("Driver cargado Exitosamente DB");
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

    }

    public ConexionDB getInstancia() throws SQLException {
        if (conexion == null) {
            conexion = new ConexionDB();
            return conexion;
        } else {
            return conexion;
        }

    }

    public  Connection getConnectionDB() {
        return con;
    }

    public static void main(String[] args) {
        try {
            ConexionDB c = new ConexionDB();
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
    }
}
